home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
macintosh-c
/
macc-carbon-demos-nonbinhex.sit
/
macc-carbon-demos-nonbinhex
/
chap23-demo-carbon events
/
Drag.h
< prev
next >
Wrap
Text File
|
2001-05-15
|
5KB
|
138 lines
// *******************************************************************************************
// Drag.h CARBON EVENT MODEL
// *******************************************************************************************
//
// This program demonstrates drag and drop utilising the Drag Manager. Support for Undo and
// Redo of drag and drop within the source window is included.
//
// The bulk of the code in the source code file Drag.c is identical to the code in the file
// Text1.c in the demonstration program MonoTextEdit (Chapter 21).
//
// The program utilises the following resources:
//
// • A 'plst' resource.
//
// • An 'MBAR' resource, and 'MENU' resources for Apple, File, and Edit menus.
//
// • A 'WIND' resource (purgeable) (initially visible).
//
// • 'CNTL' resources (purgeable) for the vertical scroll bars in the text editor window and
// Help dialog, and for the pop-up menu in the Help Dialog.
//
// • A 'STR#' resource (purgeable) containing error text strings.
//
// • A 'SIZE' resource with the acceptSuspendResumeEvents, canBackground,
// doesActivateOnFGSwitch, and isHighLevelEventAware flags set.
//
// *******************************************************************************************
// ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
#include <Carbon.h>
// …………………………………………………………………………………………………………………………………………………………………………………………………………………………… defines
#define rMenubar 128
#define mAppleApplication 128
#define iAbout 1
#define mFile 129
#define iNew 1
#define iOpen 2
#define iClose 4
#define iSaveAs 6
#define iQuit 12
#define mEdit 130
#define iUndo 1
#define iCut 3
#define iCopy 4
#define iPaste 5
#define iClear 6
#define iSelectAll 7
#define rWindow 128
#define rVScrollbar 128
#define rErrorStrings 128
#define eMenuBar 1
#define eWindow 2
#define eDocStructure 3
#define eTextEdit 4
#define eExceedChara 5
#define eNoSpaceCut 6
#define eNoSpacePaste 7
#define eDragHandler 8
#define eDrag 9
#define eDragUndo 10
#define kMaxTELength 32767
#define kTab 0x09
#define kBackSpace 0x08
#define kForwardDelete 0x7F
#define kReturn 0x0D
#define kEscape 0x1B
#define kReturn 0x0D
#define topLeft(r) (((Point *) &(r))[0])
#define botRight(r) (((Point *) &(r))[1])
// ………………………………………………………………………………………………………………………………………………………………………………………………………………………… typedefs
typedef struct
{
TEHandle textEditStrucHdl;
ControlRef vScrollbarRef;
WindowRef windowRef;
Boolean windowTouched;
Handle preDragText;
SInt16 preDragSelStart;
SInt16 preDragSelEnd;
SInt16 postDropSelStart;
SInt16 postDropSelEnd;
} docStructure, *docStructurePointer;
// …………………………………………………………………………………………………………………………………………………………………………………………… function prototypes
void main (void);
void doPreliminaries (void);
OSStatus appEventHandler (EventHandlerCallRef,EventRef,void *);
OSStatus windowEventHandler (EventHandlerCallRef,EventRef,void *);
void doIdle (void);
void doKeyEvent (SInt8);
void scrollActionFunction (ControlRef,SInt16);
void doInContent (Point,EventRecord *,Boolean);
void doDrawContent (WindowRef);
void doActivateDeactivate (WindowRef,Boolean);
void doOSEvent (EventRecord *);
WindowRef doNewDocWindow (void);
EventHandlerUPP doGetHandlerUPP (void);
Boolean customClickLoop (void);
void doSetScrollBarValue (ControlRef,SInt16 *);
void doAdjustMenus (void);
void doMenuChoice (MenuID,MenuItemIndex);
void doFileMenu (MenuItemIndex);
void doEditMenu (MenuItemIndex);
SInt16 doGetSelectLength (TEHandle);
void doAdjustScrollbar (WindowRef);
void doAdjustCursor (WindowRef);
void doCloseWindow (WindowRef);
void doSaveAsFile (TEHandle);
void doOpenCommand (void);
void doOpenFile (FSSpec);
void doErrorAlert (SInt16);
void navEventFunction (NavEventCallbackMessage,NavCBRecPtr,
NavCallBackUserData);
OSErr doStartDrag (EventRecord *,RgnHandle,TEHandle);
OSErr dragTrackingHandler (DragTrackingMessage,WindowRef,void *,DragRef);
SInt16 doGetOffset (Point,TEHandle);
SInt16 doIsOffsetAtLineStart (SInt16,TEHandle);
void doDrawCaret (SInt16,TEHandle);
SInt16 doGetLine (SInt16,TEHandle);
OSErr dragReceiveHandler (WindowRef,void *,DragRef);
Boolean doIsWhiteSpaceAtOffset (SInt16,TEHandle);
Boolean doIsWhiteSpace (char);
char doGetCharAtOffset (SInt16,TEHandle);
SInt16 doInsertTextAtOffset (SInt16,Ptr,SInt32,TEHandle);
Boolean doSavePreInsertionText (docStructurePointer);
void doUndoRedoDrag (WindowRef);
// *******************************************************************************************